import leven from "./index.js";
import er from './easy-replace.js';

let TextString = "Text entry"

// Comparison string
function ComparisonString(){
    let messaged = "dklasmjspoallkl dkaps'dka'kkap[sdkapd asdasd a"

    let Comparison;
    let startTime = Date.now();
    for (let i = 0; i < 10000; i++) {
      Comparison = leven(TextString,messaged)
    }
    let endTime = Date.now();
    if(Comparison !== 45){
      throw new Error('Easyrelpace_leven_0100 Error')
    }
    print(`Easyrelpace_leven_0100: ${endTime - startTime} ms`)
}

// Character substitution
function SimpleSubstitution(){
    let Text = ""
    let ReplaceString = "t"
    let StringResults = "马心adas"

    let startTime = Date.now();
    for (let i = 0; i < 10000; i++) {
      Text = er(
          TextString,
          {
            searchFor: ReplaceString,
          },
          StringResults
        );
    }
    let endTime = Date.now();  
    if(Text !== 'Tex马心adas en马心adasry'){
      throw new Error('Easyrelpace_er_0100 Error')
    } 
    print(`Easyrelpace_er_0100: ${endTime - startTime} ms`)
}

function Switch() {
  ComparisonString()
  SimpleSubstitution()
}
Switch()

